<template>
	<view>
		<!-- category-list：分类列表  @itemClick：条目点击 -->
		<cc-beautyCate :selected="selected" @selectedClick="selectedClick" :category-list="categoryList"
			@itemClick="toCategory"></cc-beautyCate>
	</view>
</template>
<script setup>
	import { ref } from 'vue';
	import { workAll } from '@/api/index.js'
	import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
	import util from '@/util/share.js'
	import { dataReportFun } from '@/util/dataReport.js'

	const categoryList = ref([]);
	const selected = ref(0);

	// 接收参数
	const props = ref({});
	onLoad((option) => {
		if (option) {
			props.value = option;
			selected.value = option.code;
			getTreeList();
		}
		dataReportFun({
			event: "client.page_view",
		})
	});
	
	// 切换左侧
	const selectedClick = (index) => {
		selected.value = index;
	}

	const getTreeList = async () => {
		let res = await workAll();
		categoryList.value = res.data.tree;
	}

	const toCategory = (item) => {
		uni.navigateTo({
			url: `/pages/serviceInfo/serviceInfo?id=${item.id}`
		})
	}


	// 分享
	onShareAppMessage(() => {
		return util.onShare({
			path: `/pages/classify/classify`
		})
	})
</script>
<style lang="scss">

</style>